In this lesson, we'll see how to create a simple native progress bar for our app, this being a function
of the browser window module and not a standalone API, but nonetheless, it's a very useful feature.
So being a browser window function, I'll start by demonstrating directly from Mendes's calling on the
main window instant's set progress bar with one argument being the progress.
This progress ranges from zero being empty to one being full.
So to set this to say a quarter or 25 percent, I'll pass in nought point to five save.
And they're on the app icon, we get this native progress bar indicator set to 25 per cent.
This will, of course, look different on each operating system.
But on Mark, it will show on all instances of the app icon, like, for example, in my Tabbaa, a
progress bar like this can be useful for a number of reasons.
For example, displaying the progress of a download, an export or pretty much any other long running
task.
So let's create a marked progress.
I'll cut this again, starting with an initial progress value on a progress variable nought point nought
one or one per cent, and then using an interval, we can increase this to 100 percent set interval
with a callback in which I'll set the progress as before, but this time passing the progress variable.
Next, we can check if this has reached 100 per cent or it's still in progress.
If progress is less than or equal to one meaning, we still need to set the value, one being the final
value increment progress by nought point nought one.
So one extra per cent else, meaning we've already reached 100 per cent.
Remove the progress bar by assigning it a negative value, not zero.
That gives us an empty progress bar.
It must be negative for the bar to be removed minus one.
And once the progress bar has been removed, stop the interval.
Clear interval passing progress interval.
Create that progress interval reference, let progress interval equal this interval, we still need
an interval time, I'll say 75 milliseconds, save this.
And when the app reloads, we see that progress increasing all the way to 100 percent.
Where it's removed, so a very simple function that can provide valuable information to the user.